﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SIPO.master" AutoEventWireup="false" CodeFile="monitoringPenagihan.aspx.cs" Inherits="SIPO.Web.lists.Transaction.monitoringPenagihan" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" Runat="Server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveUrl("~/styles/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/i18n/grid.locale-id.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/jquery.jqGrid.min.js") %>"></script>
    <table>
        <tr>
            <td>Nama Debitur</td>
            <td>&nbsp; :</td>
            <td>
                <asp:DropDownList ID="ddlDebitur" runat="server">
                </asp:DropDownList>            
            </td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <table id="table" class="scroll" cellpadding="0" cellspacing="0">
    </table>
    <div id="pager" class="scroll">
    </div>
    <br />
    <div id="dialog1" title="Default dialog">
    </div>
    <script type="text/javascript">
        var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Transaction/recDemandhandler.ashx") %>';

        function tampilkan(debiturId) {
            var parameter;
            if (debiturId != null) {
                parameter = '?method=getdatamonitoringupayapenagihan&DebtorID=' + debiturId;
               
            } else {
                parameter = '?method=getdatamonitoringupayapenagihan';

            }
            tableGrid(parameter);
        }
        

        function tableGrid(parameter) {
            $('#table').jqGrid({
                url: handlerUrl + parameter,
                datatype: 'json',
                colNames: ['No.','No. Tagihan', 'Kode Debitur', 'Nama Debitur','Jenis Pungutan','Tgl. Jatuh Tempo Tagihan'],
                colModel: [
                    { name: 'DebtorID', index: 'DebtorID', width: 50, align: 'center',search: false, searchoptions: { sopt: ['eq', 'cn']} },
                    { name: 'id', index: 'id', width: 100, align: 'center', hidden: true, searchoptions: { sopt: ['eq', 'cn']} },
                    { name: 'recDebtor.DebtorCode', index: 'recDebtor.DebtorCode', width: 150, align: 'center', searchoptions: { sopt: ['eq', 'cn']} },
                    { name: 'recDebtor.DebtorName', index: 'recDebtor.DebtorName', width: 200, align: 'left', searchoptions: { sopt: ['eq', 'cn']} },
                    { name: "recDemandDetail.TransName", index:"recDemandDetail.TransName", width:125, align:"center", searchoptions: { sopt: ['eq', 'cn']} },
                    { name: 'recDemandDetail.DueDate', index: 'recDemandDetail.DueDate', align: 'center', width: 150, formatter: 'date', formatoptions: { newformat: 'd M Y'}, searchoptions: { sopt: ['eq', 'cn']}  }
           	],
                rowNum: 10,
                id: 'id',
                multiselect: false,
                rowList: [5, 10, 15, 20],
                pager: '#pager',
                sortname: 'DebtorCode',
                sortorder: "asc",
                viewrecords: true,
                jsonReader: { repeatitems: false },
                height: '100%',
                caption: 'Monitoring Upaya Penagihan',
                ajaxGridOptions: { cache: false },
                subGrid: true,
                subGridRowExpanded: function(subgrid_id, row_id) {
                var subgrid_table_id, pager_id;
                subgrid_table_id = subgrid_id+"_t";
                pager_id = "p_"+subgrid_table_id;
                $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"'class='scroll'></table><div id='"+pager_id+"'class='scroll'></div>");
                $("#"+subgrid_table_id).jqGrid({
                    url: handlerUrl + '?method=getdatadetailmonitoringupayapenagihan&id=' + row_id,
                    datatype: 'json',
                    mtype: 'POST',
                    colNames: ['No.', 'Nomor Surat','Tgl. Surat','Status','Jumlah','Tgl. Jatuh Tempo Teguran'],
                    colModel:[
                        {name:"DebtorID",index:"DebtorID",width:35,key:true, align:"center"},
                        //{name:"recDemandDetail.TransNo",index:"TransNo",width:100},
                        {name:"recDemandDetail.LatterNo",index:"LatterNo",width:100,align:"center"},
                        {name: 'recDemandDetail.LatterDate', index: 'LatterDate', align: 'center', width: 100, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
                        {name:"recDemandDetail.Status",index:"Status",width:125,align:"center"},
                        {name: 'recDemandDetail.TransValue', index: 'TransValue', formatter: 'currency', align: 'right', formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2 }, width: 145 },
                        {name: 'recDemandDetail.DueDateLetter', index: 'DueDateLetter', align: 'center', width: 150, formatter: 'date', formatoptions: { newformat: 'd M Y'} }
                    ],
                    rowNum:20,
                    pager: pager_id,
                    sortname: 'LatterNo',
                    sortorder: "asc",
                    viewrecords: true,
                    height: '100%'
                });
                $("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false})
            },
            });

            $("#table").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, searchtext: 'Search', refreshtext: 'Refresh' },
        {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });
        }
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            var debtorId = '<%= Request.Params["debtorId"] %>';

            $('#<%= ddlDebitur.ClientID %>').change(function () {
                var debtorId = $('#<%= ddlDebitur.ClientID %>').val();

                var url = 'monitoringPenagihan.aspx?menuid=76&debtorId=' + debtorId;
                window.location = url;
            });
            tampilkan(debtorId);
        });
    </script>
</asp:Content>

